/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package net.jonbuck.tassoo.model.impl;

import net.jonbuck.tassoo.model.Status;
import net.jonbuck.tassoo.model.TassooPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Status</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link net.jonbuck.tassoo.model.impl.StatusImpl#getAssociatedPercentage <em>Associated Percentage</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class StatusImpl extends ReferenceModelImpl implements Status {
	/**
	 * The default value of the '{@link #getAssociatedPercentage() <em>Associated Percentage</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAssociatedPercentage()
	 * @generated
	 * @ordered
	 */
	protected static final int ASSOCIATED_PERCENTAGE_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getAssociatedPercentage() <em>Associated Percentage</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAssociatedPercentage()
	 * @generated
	 * @ordered
	 */
	protected int associatedPercentage = ASSOCIATED_PERCENTAGE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StatusImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TassooPackage.Literals.STATUS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getAssociatedPercentage() {
		return associatedPercentage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAssociatedPercentage(int newAssociatedPercentage) {
		int oldAssociatedPercentage = associatedPercentage;
		associatedPercentage = newAssociatedPercentage;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TassooPackage.STATUS__ASSOCIATED_PERCENTAGE, oldAssociatedPercentage, associatedPercentage));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public int compareTo(Status object) {
		final int BEFORE = -1;
		final int EQUAL = 0;
		final int AFTER = 1;

		if (this == object) {
			return EQUAL;
		}

		if (this.getAssociatedPercentage() > object.getAssociatedPercentage()) {
			return AFTER;
		}

		if (this.getAssociatedPercentage() < object.getAssociatedPercentage()) {
			return BEFORE;
		}

		return EQUAL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TassooPackage.STATUS__ASSOCIATED_PERCENTAGE:
				return getAssociatedPercentage();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TassooPackage.STATUS__ASSOCIATED_PERCENTAGE:
				setAssociatedPercentage((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TassooPackage.STATUS__ASSOCIATED_PERCENTAGE:
				setAssociatedPercentage(ASSOCIATED_PERCENTAGE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TassooPackage.STATUS__ASSOCIATED_PERCENTAGE:
				return associatedPercentage != ASSOCIATED_PERCENTAGE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (associatedPercentage: ");
		result.append(associatedPercentage);
		result.append(')');
		return result.toString();
	}

} //StatusImpl
